
(function(YuXi){
	var graded={};

	var color=["red","#ffa631","#00FF00","#ff7500","#057748","#7c4b00","#1685a9","#003472","#ff2d51","#60281e","#d3b17d","#00FFFF","blue","blue"];
	var object={};//分级
	graded.refresh=function(){
		$("#tablebody").find("td").each(function(){
			$(this).css("color","#000000");
		})
		var flag=-1;
		$(".thhead").find("td").each(function(){

			if($(this).html().indexOf("分级")>-1)
			{
				flag=$("table").find("td").index(this);

			}
		})
		requestcationColor();
				//向后台请求分级信息
		function requestcationColor()
		{	
		/*colorreplace();*/
		var url="getAllInformationClassification.do";//分级地址
		var data={};
		
		data=YuXi.util.get(url,"null",function(data){
			object=data.object;
			colorreplace();
		},function(){
			
		});//请求数据
		
		}
	
		function colorreplace()
		{

		
			/*object=[{name:"一级"},{name:"二级"},{name:"三级"}];*/
			var colname=[];
			for(var i=0;i<object.length;i++)
			{
				var da={};
				da.name=object[i].name;
				da.color=color[i];
				colname.push(da);
			}

			$("table tr").each(function(){
				var tdval=$(this).find("td:eq("+flag+")").html();
	 			for(var i=0;i<colname.length;i++)
				{
					
					if(tdval==colname[i].name)
					{
						$(this).find("td:eq("+flag+")").css("color",color[i]);
					}

				}
			})
		

		}



	}
	graded.get=function(){

	var flag=-1;

	$("table").find("th").each(function(){

		if($(this).html().indexOf("分级")>-1)
		{
			flag=$("table").find("th").index(this);
		}
	})
	requestcationColor();
	function colorreplace()
	{
		
		/*object=[{name:"一级"},{name:"二级"},{name:"三级"}];*/
		var colname=[];
		for(var i=0;i<object.length;i++)
		{
			var da={};
			da.name=object[i].name;
			da.color=color[i];
			colname.push(da);
		}

		$("table tr").each(function(){
			var tdval=$(this).find("td:eq("+flag+")").html();
 			for(var i=0;i<colname.length;i++)
			{
				
				if(tdval==colname[i].name)
				{
					$(this).find("td:eq("+flag+")").css("color",color[i]);
				}

			}
		})
		

	}
	
 
		//向后台请求分级信息
		function requestcationColor()
		{	
		/*colorreplace();*/
		var url="getAllInformationClassification.do";//分级地址
		var data={};
		
		data=YuXi.util.get(url,"null",function(data){
			object=data.object;
			colorreplace();
		},function(){
			
		});//请求数据
		
		}

	}
	YuXi.graded=graded;
})(window.YuXi)
